package db

import (
	"gorm.io/driver/postgres"
	"gorm.io/gorm"

	"aicloud/monitor-apiserver/pkg/util"
)

type PostgresDb struct {
	DB
}

func init() {
	RegisterFunc["postgres"] = func(url string) Database {
		dial := postgres.Open(url)
		db, err := gorm.Open(dial, &gorm.Config{})
		if err != nil {
			util.GetLogger().Fatalf("db init failed:%v", err)
		}
		return &PostgresDb{
			DB: DB{DB: db},
		}
	}
}
